package sort.sort;

public class BubbleSort3 extends Sort{
    @Override
    protected void sort() {
        for (int end = array.length-1; end > 1;end-- ) {
            int endIndex = 1;
            for (int begin = 1;begin <= end ;begin++) {
                if (cmp(array[begin-1],array[begin]) > 0) {
                    swap(begin-1,begin);
                    endIndex = begin;
                }
            }
            end = endIndex;
        }
    }
}
